package com.blb.service.user.impl;

import com.blb.dao.admin.impl.CarouselDaoImpl;
import com.blb.dao.admin.impl.ProductDaoImpl;
import com.blb.dao.admin.impl.ProductTypeDaoImpl;
import com.blb.dao.user.impl.IndexDaoImpl;
import com.blb.pojo.Carousel;
import com.blb.pojo.Product;
import com.blb.pojo.ProductType;
import com.blb.service.user.IIndexService;
import com.blb.utils.ApplicationContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

@Service
public class IndexServiceImpl implements IIndexService {

    @Autowired
    private IndexDaoImpl indexDao;
    @Autowired
    private CarouselDaoImpl carouselDao;
    @Autowired
    private ProductDaoImpl productDao;


    @Override
    public List<Carousel> getCarousel() throws Exception {
        List<Carousel> list = carouselDao.getCarousel();
        return list;
    }

    @Override
    public List<Product> getNewProduct() throws Exception {
        List<Product> list = indexDao.selectNewProduct();
        return list;
    }

    @Override
    public List<ProductType> getProductType() throws Exception {
        return indexDao.selectProductType();
    }

    @Override
    public List<Product> getProductAndBrand(String id) throws Exception {
        return productDao.selectProductAndBrand(id);
    }

    @Override
    public void setOrderData(int id, int productId, int num) throws SQLException, ClassNotFoundException {
        indexDao.insertOrderData(id,productId,num);
    }

    @Override
    public List<Product> selectProduct() throws Exception {
        return indexDao.selectProduct();
    }
}
